<?php
header("Content-type:text/html;charset=utf-8");
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,"https://www.readnovel.com/");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
$res=curl_exec($ch);
$para = '#<li data-rid=".*"><div class="book-img"><a href="(.*)" data-eid="qd_F23" data-bid=".*" target="_blank"><img src=".*" alt=".*"></a></div><div class="book-info"><h4><a href=".*" data-eid="qd_F24" data-bid=".*" target="_blank" title=".*">(.*)</a></h4><p>(.*)</p><div class="state-box cf"><i>(.*)</i><a class="author default" data-eid="qd_F25" target="_blank"><img src="//qidian.gtimg.com/readnovel/images/ico/user.f22d3.png">(.*)</a></div></div></li>#isU';
preg_match_all($para,$res,$arr);

echo "<pre>";
var_dump($arr);

$pdo=new PDO("mysql:host=127.0.0.1;dbname=tianshl_ae","root","root");
$pdo->beginTransaction();
foreach ($arr[1] as $k => $v) {
    $title=$arr[2][$k];
    $home_a=$arr[3][$k];
    $home_b=$arr[4][$k];
    $home_c=$arr[5][$k];
    $res=$pdo->exec("insert into `test1` (luj,title,test_a,stru,zuoze) values ('$v','$title','$home_a','$home_b','$home_c')");
}
if ($res) {
    //提交一个事务
    $pdo->commit();
    echo "<a href='tianshl_1.php'>跳转展示页面</a>";
    // var_dump($pdo);
} else {
    //回滚一个事务
    $pdo->rollBack();
}
?>